<?php
include "config.php";
$pilihan = mysql_real_escape_string ($_POST['pilihan']);
echo "<table width=95% align=center><tr><td><font size=2>>> Hasil Poling</font></td></tr></table><br /><br />";
$agoes = mysql_fetch_array (mysql_query ("select * from polling where id_polling='$pilihan'"));
$rating = $agoes['rating']+1;
$u = mysql_query("UPDATE polling SET rating='$rating' WHERE id_polling='$_POST[pilihan]'");
echo "<p align=center><font face=tahoma size=2>Terimakasih atas partisipasi Anda mengikuti poling kami<br /><br />
Hasil poling saat ini: </font></p><br />";
echo "<table width=90% align=center style='border: 1pt dashed #0000CC;padding: 10px;'>";
$jml=mysql_query("SELECT SUM(rating) as jml_vote FROM polling WHERE aktif='Y'");
$j=mysql_fetch_array($jml);
$jml_vote=$j['jml_vote'];
$sql=mysql_query("SELECT * FROM polling WHERE aktif='Y'");
while ($s=mysql_fetch_array($sql)){
  	$prosentase = sprintf("%2.1f",(($s['rating']/$jml_vote)*100));
  	$gbr_vote   = $prosentase * 3;
    echo "<tr><td width=120>$s[pilihan] ($s[rating]) </td><td> 
          <img src=images/blue.png width=$gbr_vote height=18 border=0> $prosentase % 
          </td></tr>";  
}
echo "</table>
<p><table width=90% align=center style='border: 0pt dashed #0000CC;padding: 10px;'><tr><td>Jumlah Voting: <b>$jml_vote</b></td></tr></table></p>";
echo "</div>
</div>";            
?>